<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<script>
    function Queue(){
        this.data=[];
    }
    Queue.prototype={
        constructor:Queue,
        enqueue: function (elm) {//入队
            this.data.push(elm);
        },
        dequeue: function () {//出队
            return this.data.shift();
        },
        front: function () {//获取队首元素
            return this.data[0];
        },
        back: function () {//获取队尾元素
            return this.data[this.length-1];
        },
        clear: function () {//清空
            delete this.data;
            this.data=[];
        },
        isEmpty: function () {//是否为空
            return this.data.length==0?true:false;
        },
        toString: function () {//显示
            return this.data.join('\n');
        }
    }
</script>
</body>
</html>